package com.wd.car.view.activity

import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
import com.wd.base.BaseActivity
import com.wd.base.MyViewModel
import com.wd.car.R
import com.wd.car.databinding.ActivityHomeBinding

@Route(path = "/activity/homeactivity")
class HomeActivity : BaseActivity<MyViewModel,ActivityHomeBinding>(R.layout.activity_home) {

    val tabName = arrayOf("首页", "购物车", "订单", "我的")
    val icons = intArrayOf(
        R.mipmap.ic_launcher,
        R.mipmap.ic_launcher,
        R.mipmap.ic_launcher,
        R.mipmap.ic_launcher
    )

    override fun dataObserver() {

    }

    override fun initView() {

        //TODO 实现导航切换
        //TODO navigation 相关的类
//        val navHostFragment: NavHostFragment? = supportFragmentManager.findFragmentById(R.id.fragment_id) as NavHostFragment?
//        val controller: NavController = navHostFragment.getNavController()
//        //TODO TabLayout 的初始
//        for (i in tabName.indices) {
//            dataBinding.tabLayout.addTab(
//                dataBinding.tabLayout.newTab().setText(tabName[i]).setIcon(icons[i])
//            )
//        }
//        //TODO 联动
//        dataBinding.tabLayout.addOnTabSelectedListener(object : OnTabSelectedListener {
//            override fun onTabSelected(tab: TabLayout.Tab) {
//                when (tab.position) {
////                    0 -> controller.navigate(R.id.homeFragment)
////                    1 -> controller.navigate(R.id.carFragment)
////                    2 -> controller.navigate(R.id.orderFragment)
////                    3 -> controller.navigate(R.id.mineFragment)
//                }
//            }
//
//            override fun onTabUnselected(tab: TabLayout.Tab) {}
//            override fun onTabReselected(tab: TabLayout.Tab) {}
//        })
    }

}